<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改在外人员情况')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-zwryqk-edit" th:object="${zwryqk}">
            <input name="id" th:field="*{id}" type="hidden">
          <!--  <div class="form-group">
                <label class="col-sm-3 control-label">人员id：</label>
                <div class="col-sm-8">
                    <input name="userid" th:field="*{userid}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">科室id：</label>
                <div class="col-sm-8">
                    <input name="keshiid" th:field="*{keshiid}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">科室名称：</label>
                <div class="col-sm-8">
                    <input name="keshiname" th:field="*{keshiname}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">离宁时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="liningtime" th:value="${#dates.format(zwryqk.liningtime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">旅居具体地点：</label>
                <div class="col-sm-8">
                    <input name="text1" th:field="*{text1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">在外原因：</label>
                <div class="col-sm-8">
                    <input name="zaiwaiyuanyin" th:field="*{zaiwaiyuanyin}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">人员类别：</label>
                <div class="col-sm-8">
                   <!-- <input name="renyuanleibie" th:field="*{renyuanleibie}" class="form-control" type="text">-->
                    <select name="renyuanleibie" class="form-control" th:field="*{renyuanleibie}">
                        <option value="">--请选择--</option>
                        <option value="1">干部</option>
                        <option value="2">柿饼</option>
                        <option value="3">文职</option>
                        <option value="4">职工</option>
                        <option value="5">聘用制</option>
                        <option value="6">博士后</option>
                        <option value="7">劳务派遣</option>
                        <option value="8">进修（实习）生</option>
                        <option value="9">零时工</option>
                        <option value="10">其他</option>
                    </select>

                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">健康码颜色：</label>
                <div class="col-sm-8">
                    <input name="yanse" th:field="*{yanse}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">电话：</label>
                <div class="col-sm-8">
                    <input name="dianhua" th:field="*{dianhua}" class="form-control" type="text">
                </div>
            </div>
           <!-- <div class="form-group">
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="chuangjiantime" th:value="${#dates.format(zwryqk.chuangjiantime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="beizhu" th:field="*{beizhu}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control" th:field="*{status}">
                        <option value="">--请选择--</option>
                        <option value="1">有效</option>
                        <option value="0">失效</option>
                    </select>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="status" value="">
                        <label th:for="status" th:text="未知"></label>
                    </div>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注1：</label>
                <div class="col-sm-8">
                    <input name="text1" th:field="*{text1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注2：</label>
                <div class="col-sm-8">
                    <input name="text2" th:field="*{text2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注3：</label>
                <div class="col-sm-8">
                    <input name="text3" th:field="*{text3}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">
                <div class="col-sm-12" style="text-align:center;">
                    <a class="btn btn-success btn-rounded btn-sm" onclick="edit()">&nbsp;保存</a>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/zwryqk";
        $("#form-zwryqk-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-zwryqk-edit').serialize());
            }
        }
        function edit() {

            var zwryqk = new Object();

            zwryqk.id = $("input[name='id']").val();
            zwryqk.userid = $("input[name='userid']").val();
            zwryqk.keshiid = $("input[name='keshiid']").val();
            zwryqk.keshiname = $("input[name='keshiname']").val();
            zwryqk.liningtime = $("input[name='liningtime']").val();
            zwryqk.zaiwaiyuanyin = $("input[name='zaiwaiyuanyin']").val();
            zwryqk.renyuanleibie = $("select[name='renyuanleibie']").val();
            zwryqk.yanse = $("input[name='yanse']").val();
            zwryqk.dianhua = $("input[name='dianhua']").val();
            zwryqk.beizhu = $("input[name='beizhu']").val();
            zwryqk.lvjudi = $("input[name='text1']").val();
            zwryqk.status = $("select[name='status']").val();

            if(!zwryqk.keshiname){
                alert("请填写科室！");
                return false;
            }
            if(!zwryqk.liningtime){
                alert("请选择离宁时间！");
                return false;
            }
            if(!zwryqk.lvjudi){
                alert("请填写旅居具体地点！");
                return false;
            }
            if(!zwryqk.zaiwaiyuanyin){
                alert("请填写在外原因！");
                return false;
            }
            if(!zwryqk.renyuanleibie){
                alert("请选择人员类别！");
                return false;
            }
            if(!zwryqk.yanse){
                alert("请填写健康码颜色！");
                return false;
            }
            if(!zwryqk.dianhua){
                alert("请填写电话");
                return false;
            }else{
                let pattern = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
                if(!pattern.test(zwryqk.dianhua)){
                    alert("电话号码填写错误");
                    return false;
                }

            }

            $.ajax({
                type: "post",
                url:  prefix+"/edit",
                data: {
                    "id":zwryqk.id,
                    "userid":zwryqk.userid,
                    "keshiid":zwryqk.keshiid,
                    "keshiname":zwryqk.keshiname,
                    "liningtime":zwryqk.liningtime,
                    "zaiwaiyuanyin":zwryqk.zaiwaiyuanyin,
                    "renyuanleibie":zwryqk.renyuanleibie,
                    "yanse":zwryqk.yanse,
                    "dianhua":zwryqk.dianhua,
                    "beizhu":zwryqk.beizhu,
                    "lvjudi":zwryqk.lvjudi,
                    "status":zwryqk.status
                },
                success: function(r) {
                    if (r.code == 0) {
                        $.modal.close();
                        parent.$.modal.msgSuccess(r.msg);
                        parent.$.table.refresh();
                    } else {

                        alert(r.msg);
                    }
                }
            });
        }

        $("input[name='liningtime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='chuangjiantime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>